import { defineStore } from 'pinia'

export const useInquiryStore = defineStore('inquiry', {
  state: () => ({
    inquiries: [],
    currentInquiry: null
  }),

  getters: {
    getInquiries: (state) => state.inquiries,
    getCurrentInquiry: (state) => state.currentInquiry
  },

  actions: {
    // 获取统计数据
    async getStatistics(params) {
      // 模拟统计数据
      return {
        trendData: [120, 200, 150, 80, 70, 110, 130],
        replyRateData: [
          { value: 1048, name: '已回复' },
          { value: 735, name: '未回复' }
        ],
        questionTypeData: [
          { value: 1048, name: '技术问题' },
          { value: 735, name: '商务问题' },
          { value: 580, name: '资质问题' },
          { value: 484, name: '其他问题' }
        ],
        responseTimeData: [120, 200, 150, 80, 70, 110]
      }
    },

    // 获取询标列表
    async getInquiryList() {
      // 模拟询标列表数据
      this.inquiries = [
        {
          id: 1,
          projectId: 'P001',
          projectName: '示例项目1',
          content: '这是一个示例询标内容',
          status: 'pending',
          createTime: '2024-03-20 10:00:00'
        },
        {
          id: 2,
          projectId: 'P002',
          projectName: '示例项目2',
          content: '这是另一个示例询标内容',
          status: 'replied',
          createTime: '2024-03-19 15:30:00'
        }
      ]
      return this.inquiries
    },

    // 获取询标详情
    async getInquiryDetail(id) {
      // 模拟询标详情数据
      this.currentInquiry = {
        id,
        projectId: 'P001',
        projectName: '示例项目',
        content: '这是一个示例询标内容',
        status: 'pending',
        createTime: '2024-03-20 10:00:00',
        files: [
          {
            name: '示例文件1.pdf',
            size: 1024 * 1024,
            url: '#'
          }
        ],
        replies: [
          {
            content: '这是一个示例回复',
            replyTime: '2024-03-20 11:00:00',
            files: []
          }
        ]
      }
      return this.currentInquiry
    }
  }
}) 